{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "checked-orange",
   "metadata": {},
   "source": [
    "# OutlierTrimmer\n",
    "The OutlierTrimmer() removes observations with outliers from the dataset.\n",
    "\n",
    "It works only with numerical variables. A list of variables can be indicated.\n",
    "Alternatively, the OutlierTrimmer() will select all numerical variables.\n",
    "\n",
    "The OutlierTrimmer() first calculates the maximum and /or minimum values\n",
    "beyond which a value will be considered an outlier, and thus removed.\n",
    "\n",
    "Limits are determined using:\n",
    "\n",
    "- a Gaussian approximation\n",
    "- the inter-quantile range proximity rule\n",
    "- percentiles.\n",
    "\n",
    "### Example:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "original-pasta",
   "metadata": {},
   "outputs": [],
   "source": [
    "# importing libraries\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "from sklearn.model_selection import train_test_split\n",
    "\n",
    "from feature_engine.outliers import OutlierTrimmer"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "planned-programmer",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Load titanic dataset from OpenML\n",
    "\n",
    "def load_titanic():\n",
    "    data = pd.read_csv(\n",
    "        'https://www.openml.org/data/get_csv/16826755/phpMYEkMl')\n",
    "    data = data.replace('?', np.nan)\n",
    "    data['cabin'] = data['cabin'].astype(str).str[0]\n",
    "    data['pclass'] = data['pclass'].astype('O')\n",
    "    data['embarked'].fillna('C', inplace=True)\n",
    "    data['fare'] = data['fare'].astype('float')\n",
    "    data['fare'].fillna(data['fare'].median(), inplace=True)\n",
    "    data['age'] = data['age'].astype('float')\n",
    "    data['age'].fillna(data['age'].median(), inplace=True)\n",
    "    data.drop(['name', 'ticket'], axis=1, inplace=True)\n",
    "    return data\n",
    "\n",
    "# To plot histogram of given numerical feature\n",
    "\n",
    "\n",
    "def plot_hist(data, col):\n",
    "    plt.figure(figsize=(8, 5))\n",
    "    plt.hist(data[col], bins=30)\n",
    "    plt.title(\"Distribution of \" + col)\n",
    "    return plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "objective-professor",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>pclass</th>\n",
       "      <th>survived</th>\n",
       "      <th>sex</th>\n",
       "      <th>age</th>\n",
       "      <th>sibsp</th>\n",
       "      <th>parch</th>\n",
       "      <th>fare</th>\n",
       "      <th>cabin</th>\n",
       "      <th>embarked</th>\n",
       "      <th>boat</th>\n",
       "      <th>body</th>\n",
       "      <th>home.dest</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>675</th>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>male</td>\n",
       "      <td>21.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>7.775</td>\n",
       "      <td>n</td>\n",
       "      <td>S</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Brennes, Norway New York</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>558</th>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>female</td>\n",
       "      <td>18.0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>13.000</td>\n",
       "      <td>n</td>\n",
       "      <td>S</td>\n",
       "      <td>16</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Finland / Minneapolis, MN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>194</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>male</td>\n",
       "      <td>30.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>26.000</td>\n",
       "      <td>C</td>\n",
       "      <td>S</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Brockton, MA</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>217</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>male</td>\n",
       "      <td>64.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>26.000</td>\n",
       "      <td>n</td>\n",
       "      <td>S</td>\n",
       "      <td>NaN</td>\n",
       "      <td>263</td>\n",
       "      <td>Isle of Wight, England</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>473</th>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>male</td>\n",
       "      <td>28.0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0.000</td>\n",
       "      <td>n</td>\n",
       "      <td>S</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Belfast</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    pclass  survived     sex   age  sibsp  parch    fare cabin embarked boat  \\\n",
       "675      3         0    male  21.0      0      0   7.775     n        S  NaN   \n",
       "558      2         1  female  18.0      0      2  13.000     n        S   16   \n",
       "194      1         0    male  30.0      0      0  26.000     C        S  NaN   \n",
       "217      1         0    male  64.0      0      0  26.000     n        S  NaN   \n",
       "473      2         0    male  28.0      0      0   0.000     n        S  NaN   \n",
       "\n",
       "    body                  home.dest  \n",
       "675  NaN   Brennes, Norway New York  \n",
       "558  NaN  Finland / Minneapolis, MN  \n",
       "194  NaN               Brockton, MA  \n",
       "217  263     Isle of Wight, England  \n",
       "473  NaN                    Belfast  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Loading titanic dataset\n",
    "data = load_titanic()\n",
    "data.sample(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "nervous-interference",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "train data shape before removing outliers: (916, 11)\n",
      "test data shape before removing outliers: (393, 11)\n"
     ]
    }
   ],
   "source": [
    "# let's separate into training and testing set\n",
    "\n",
    "X_train, X_test, y_train, y_test = train_test_split(data.drop('survived', axis=1),\n",
    "                                                    data['survived'],\n",
    "                                                    test_size=0.3,\n",
    "                                                    random_state=0)\n",
    "\n",
    "print(\"train data shape before removing outliers:\", X_train.shape)\n",
    "print(\"test data shape before removing outliers:\", X_test.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "medium-chile",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Max age: 80.0\n",
      "Max fare: 512.3292\n",
      "Min age: 0.1667\n",
      "Min fare: 0.0\n"
     ]
    }
   ],
   "source": [
    "# let's find out the maximum Age and maximum Fare in the titanic\n",
    "\n",
    "print(\"Max age:\", data.age.max())\n",
    "print(\"Max fare:\", data.fare.max())\n",
    "\n",
    "print(\"Min age:\", data.age.min())\n",
    "print(\"Min fare:\", data.fare.min())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "suburban-mills",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAeYAAAE/CAYAAACTomAoAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAZM0lEQVR4nO3de7SldX3f8fdHhoAC4SKndJwBBpVqiKsOdkRc2gRBI+AFs1ZicHmZWLImbTHRhCSCG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<Figure size 576x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Histogram of age feature before capping outliers\n",
    "plot_hist(data, 'age')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "compatible-finish",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAeYAAAE/CAYAAACTomAoAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAYCElEQVR4nO3dfbTdVZ3f8fdHAjLjA+HhmsUkgeCQ6jBdFWlq49KpSkbLgzX84TC4HIk0s9LVUqvVWU58GKtdtsV2KSN9oGWJNfiMzFgySh1jwOXMWgMaFJAHlSsFkxhIRAgCoyP67R9nXz3EhHvuzb3J5uT9Wuuss39779/vt88ml09++/e7J6kqJElSH55ysAcgSZJ+yWCWJKkjBrMkSR0xmCVJ6ojBLElSRwxmSZI6YjBLcyDJ/0zyJ3N0rBOSPJzksLb95SR/OBfHbsf7v0nWzNXxZnDe9yb5QZJ799H+L5Pc1z77sQd6fFIv4u8xS08syd3AIuAx4GfA7cAVwGVV9fNZHOsPq+pLM9jny8DHqupDMzlX2/fdwMlV9Qcz3XcuJTkB+DZwYlXt3Ev74cBDwMqquvlAj0/qiVfM0mj+WVU9AzgRuAj4Y+DyuT5JkgVzfcxOnADcv7dQbhYBRwK3zebgYzxvOgQZzNIMVNXuqtoI/D6wJsnfB0jykSTvbeXjknwuyYNJfpjkr5I8JclHGQTUX7Tl2rcmWZakkqxN8j3g2qG64bD5zSRfTfJQkquTHNPO9dIk24bHmOTuJL+b5Azg7cDvt/Pd3Np/sTTexvXOJPck2ZnkiiRHtbapcaxJ8r22DP2Ofc1NkqPa/rva8d7Zjv+7wCbgN9o4PrLHfn+PwdU0wINJrm31H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/csKUYAcL4/kAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 576x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Histogram of fare feature before capping outliers\n",
    "plot_hist(data, 'fare')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "weighted-palestinian",
   "metadata": {},
   "source": [
    "### Outlier trimming using Gaussian limits:\n",
    "The transformer will find the maximum and / or minimum values to\n",
    "    trim the variables using the Gaussian approximation.\n",
    "\n",
    "\n",
    "- right tail: mean + 3* std\n",
    "- left tail: mean - 3* std"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "micro-knitting",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "OutlierTrimmer(variables=['age', 'fare'])"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'''Parameters\n",
    "----------\n",
    "\n",
    "capping_method : str, default=gaussian\n",
    "    Desired capping method. Can take 'gaussian', 'iqr' or 'quantiles'.\n",
    "    \n",
    "tail : str, default=right\n",
    "    Whether to cap outliers on the right, left or both tails of the distribution.\n",
    "    Can take 'left', 'right' or 'both'.\n",
    "\n",
    "fold: int or float, default=3\n",
    "    How far out to to place the capping values. The number that will multiply\n",
    "    the std or IQR to calculate the capping values.\n",
    "\n",
    "variables : list, default=None\n",
    "\n",
    "missing_values: string, default='raise'\n",
    "    Indicates if missing values should be ignored or raised.'''\n",
    "\n",
    "# removing outliers based on right tail of age and fare columns using gaussian capping method\n",
    "trimmer = OutlierTrimmer(\n",
    "    capping_method='gaussian', tail='right', fold=3, variables=['age', 'fare'])\n",
    "\n",
    "# fitting trimmer object to training data\n",
    "trimmer.fit(X_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "revolutionary-giant",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'age': 67.49048447470315, 'fare': 174.78162171790441}"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# here we can find the maximum caps allowed\n",
    "trimmer.right_tail_caps_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "requested-paint",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{}"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# this dictionary is empty, because we selected only right tail\n",
    "trimmer.left_tail_caps_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "extreme-contribution",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Max age: 66.0\n",
      "Max fare: 164.8667\n"
     ]
    }
   ],
   "source": [
    "# transforming the training and testing data\n",
    "train_t = trimmer.transform(X_train)\n",
    "test_t = trimmer.transform(X_test)\n",
    "\n",
    "# let's check the new maximum Age and maximum Fare in the titanic\n",
    "print(\"Max age:\", train_t.age.max())\n",
    "print(\"Max fare:\", train_t.fare.max())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "mobile-charger",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "train data shape after removing outliers: (887, 11)\n",
      "29 observations are removed\n",
      "\n",
      "test data shape after removing outliers: (376, 11)\n",
      "17 observations are removed\n"
     ]
    }
   ],
   "source": [
    "print(\"train data shape after removing outliers:\", train_t.shape)\n",
    "print(f\"{X_train.shape[0] - train_t.shape[0]} observations are removed\\n\")\n",
    "\n",
    "print(\"test data shape after removing outliers:\", test_t.shape)\n",
    "print(f\"{X_test.shape[0] - test_t.shape[0]} observations are removed\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "duplicate-automation",
   "metadata": {},
   "source": [
    "### Gaussian approximation trimming, both tails"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "fifteen-parker",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "OutlierTrimmer(fold=2, tail='both', variables=['fare', 'age'])"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Trimming the outliers at both tails using gaussian  method\n",
    "trimmer = OutlierTrimmer(\n",
    "    capping_method='gaussian', tail='both', fold=2, variables=['fare', 'age'])\n",
    "trimmer.fit(X_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "meaningful-kinase",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Minimum caps : {'fare': -62.30099726608475, 'age': 4.681562024142586}\n",
      "Maximum caps : {'fare': 127.36509792110658, 'age': 54.92869998459104}\n"
     ]
    }
   ],
   "source": [
    "print(\"Minimum caps :\", trimmer.left_tail_caps_)\n",
    "\n",
    "print(\"Maximum caps :\", trimmer.right_tail_caps_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "confidential-tradition",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "train data shape after removing outliers: (803, 11)\n",
      "113 observations are removed\n",
      "\n",
      "test data shape after removing outliers: (334, 11)\n",
      "59 observations are removed\n"
     ]
    }
   ],
   "source": [
    "# transforming the training and testing data\n",
    "train_t = trimmer.transform(X_train)\n",
    "test_t = trimmer.transform(X_test)\n",
    "\n",
    "print(\"train data shape after removing outliers:\", train_t.shape)\n",
    "print(f\"{X_train.shape[0] - train_t.shape[0]} observations are removed\\n\")\n",
    "\n",
    "print(\"test data shape after removing outliers:\", test_t.shape)\n",
    "print(f\"{X_test.shape[0] - test_t.shape[0]} observations are removed\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fundamental-address",
   "metadata": {},
   "source": [
    "### Inter Quartile Range, both tails\n",
    "The transformer will find the boundaries using the IQR proximity rule.\n",
    "**IQR limits:**\n",
    "\n",
    "- right tail: 75th quantile + 3* IQR\n",
    "- left tail:  25th quantile - 3* IQR\n",
    "\n",
    "where IQR is the inter-quartile range: 75th quantile - 25th quantile.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "closed-knight",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "OutlierTrimmer(capping_method='iqr', tail='both', variables=['age', 'fare'])"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# trimming at both tails using iqr capping method\n",
    "trimmer = OutlierTrimmer(\n",
    "    capping_method='iqr', tail='both', variables=['age', 'fare'])\n",
    "\n",
    "trimmer.fit(X_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "psychological-holmes",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Minimum caps : {'age': -13.0, 'fare': -62.24179999999999}\n",
      "Maximum caps : {'age': 71.0, 'fare': 101.4126}\n"
     ]
    }
   ],
   "source": [
    "print(\"Minimum caps :\", trimmer.left_tail_caps_)\n",
    "\n",
    "print(\"Maximum caps :\", trimmer.right_tail_caps_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "neither-enlargement",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "train data shape after removing outliers: (857, 11)\n",
      "59 observations are removed\n",
      "\n",
      "test data shape after removing outliers: (365, 11)\n",
      "28 observations are removed\n"
     ]
    }
   ],
   "source": [
    "# transforming the training and testing data\n",
    "train_t = trimmer.transform(X_train)\n",
    "test_t = trimmer.transform(X_test)\n",
    "\n",
    "print(\"train data shape after removing outliers:\", train_t.shape)\n",
    "print(f\"{X_train.shape[0] - train_t.shape[0]} observations are removed\\n\")\n",
    "\n",
    "print(\"test data shape after removing outliers:\", test_t.shape)\n",
    "print(f\"{X_test.shape[0] - test_t.shape[0]} observations are removed\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "robust-highland",
   "metadata": {},
   "source": [
    "### percentiles or quantiles:\n",
    "The limits are given by the percentiles.\n",
    "- right tail: 98th percentile\n",
    "- left tail:  2nd percentile"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "egyptian-northwest",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "OutlierTrimmer(capping_method='quantiles', fold=0.02, tail='both',\n",
       "               variables=['age', 'fare'])"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# trimming at both tails using quantiles capping method\n",
    "trimmer = OutlierTrimmer(capping_method='quantiles',\n",
    "                         tail='both', fold=0.02, variables=['age', 'fare'])\n",
    "\n",
    "trimmer.fit(X_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "banner-logistics",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Minimum caps : {'age': 2.0, 'fare': 6.44125}\n",
      "Maximum caps : {'age': 61.69999999999993, 'fare': 211.5}\n"
     ]
    }
   ],
   "source": [
    "print(\"Minimum caps :\", trimmer.left_tail_caps_)\n",
    "\n",
    "print(\"Maximum caps :\", trimmer.right_tail_caps_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "familiar-climate",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "train data shape after removing outliers: (852, 11)\n",
      "64 observations are removed\n",
      "\n",
      "test data shape after removing outliers: (358, 11)\n",
      "35 observations are removed\n"
     ]
    }
   ],
   "source": [
    "# transforming the training and testing data\n",
    "train_t = trimmer.transform(X_train)\n",
    "test_t = trimmer.transform(X_test)\n",
    "\n",
    "print(\"train data shape after removing outliers:\", train_t.shape)\n",
    "print(f\"{X_train.shape[0] - train_t.shape[0]} observations are removed\\n\")\n",
    "\n",
    "print(\"test data shape after removing outliers:\", test_t.shape)\n",
    "print(f\"{X_test.shape[0] - test_t.shape[0]} observations are removed\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "usual-playlist",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAeYAAAE/CAYAAACTomAoAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAYTklEQVR4nO3dfbRddX3n8ffHBLUKFZA7DAIhoKktumq0VweXD0WxFfEBnTWDsHyIlE50Bjs6xXEQrVCXdOgD2HHa4qRCwSeEiihVakVKi66p0KCICFqBBkkMSQQRBAcNfOePsyOHm5vcm3vOzf3lnPdrrbPO3r/99M0vOfnc/dv77JuqQpIkteFRC12AJEl6mMEsSVJDDGZJkhpiMEuS1BCDWZKkhhjMkiQ1xGCWhiDJh5L83pD2tSTJj5Ms6ub/IclvD2Pf3f7+NsmKYe1vB477/iQ/SHLHzj62tCuJ32OWti/JGmBfYDPwIHAj8BFgVVU9NId9/XZVfWkHtvkH4GNV9eEdOVa37WnAU6rq9Tu67TAlWQJ8BzioqjYuZC1S6zxjlmbnlVW1B3AQcAbwP4Bzhn2QJIuHvc9GLAHuNJSlmRnM0g6oqh9V1aXAa4EVSZ4OkOS8JO/vpvdJ8rkkdye5K8mXkzwqyUfpBdTfdEPV70yyNEklOSHJ94C/72vrD+knJ7kmyT1JPptk7+5YhydZ219jkjVJXpLkSOAU4LXd8b7RLf/50HhX13uS3JZkY5KPJHlCt2xLHSuSfK8bhn73tvomyRO67Td1+3tPt/+XAJcDT+rqOG+abffq+mxTkh920wf0LT84yVVJ7k3ypSR/nuRjfcsPS/J/uz7/RpLDZ/lXKjXHYJbmoKquAdYCL5hm8Undsgl6Q+Cn9DapNwDfo3f2vXtV/VHfNr8O/Arw0m0c8o3AbwH70RtS/+AsavwC8AfAhd3xnjHNam/qXi8CDgF2B/5syjrPB54KHAG8N8mvbOOQ/xt4QrefX+9qPr4btn8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
      "text/plain": [
       "<Figure size 576x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Histogram of age feature after removing outliers\n",
    "plot_hist(train_t, 'age')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "yellow-group",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAeYAAAE/CAYAAACTomAoAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAYf0lEQVR4nO3dfdCddX3n8fdHgtgWakDuZjAJhip9wM4YnBTZ0a4IVXlwG5yxFKeFyOLE3cWurnY1WFtxR3bp7iKr25VdFJbgE1LUJVVqRcCxzlQwWEQeSs1ikMRAIs9oZZv43T/OL/U05uZ+zv3j3O/XzJlzXb/r6XvONef+5Pc717mSqkKSJPXhGfNdgCRJ+gmDWZKkjhjMkiR1xGCWJKkjBrMkSR0xmCVJ6ojBLM2CJP8zyR/N0r4OT/JEkv3a/JeTvHE29t329xdJ1szW/qZw3Pcl+X6S+8dZ/q+TPNBe+3P2dX1SL+LvmKWnlmQzsATYCewC7gSuAC6pqh9PY19vrKovTWGbLwMfq6qPTOVYbdvzgBdU1e9NddvZlORw4G7geVW1fS/L9wceA46tqm/u6/qknthjlibnX1TVQcDzgAuAdwKXzvZBkiya7X124nDgwb2FcrMEeBZwx3R2PsLvmxYgg1magqp6tKo2AL8DrEnyawBJLk/yvjZ9aJLPJXkkyUNJ/irJM5J8lEFA/Xkbrn1HkhVJKsnZSb4L3DDUNhw2z09yc5LHklyT5JB2rOOSbBmuMcnmJL+Z5ETgXcDvtON9sy3/x6HxVte7k9ybZHuSK5I8uy3bXceaJN9tw9B/ON57k+TZbfsdbX/vbvv/TeA64Lmtjsv32O6XGPSmAR5JckNr/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djn4rgkKxkMmW4G3gRQVXckuYrB/z2/EzinqnbNQ9mj6qXAGcC3ktza2t7FiH02vPOXJEkd6XkoW5KkBcdgliSpIwazJEkdMZglSeqIwSxJUkcMZkmSOmIwS5LUEYNZkqSO/H9/wuc5D3DShgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 576x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Histogram of fare feature after removing outliers\n",
    "plot_hist(train_t, 'fare')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "unavailable-geography",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
